package com.dragonwu.controller;

import com.dragonwu.model.LoginResult;
import com.dragonwu.service.SysLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author DragonWu
 * @since 2022-10-11 8:41
 **/
@RestController
public class SysUserLoginController {

    @Autowired
    private SysLoginService sysLoginService;

    @PostMapping("/login")
    public LoginResult login(
            @RequestParam("username") String username,
            @RequestParam("password") String password
    ){
        try{
            return sysLoginService.login(username,password);
        }catch (RuntimeException msg){
            System.out.println(msg);
            return null;
        }
    }
}
